﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SurveyHost.Models
{
    public partial class Configuration : BaseDataModel<Configuration>
    {
        /// <summary>
        /// Retrieves the latest configuration.
        /// </summary>
        /// <returns><see cref="Configuration"/></returns>
        public static Configuration Retrieve()
        {
            using (var context = GetContext())
            {
                var result = context.Configurations.LastOrDefault();
                if (result != null)
                    return result;

                context.Configurations.InsertOnSubmit(new Configuration());
                context.SubmitChanges();
                return context.Configurations.Last();
            }
        }

    }
}
